package handlers

import (
	"InstantImage/middleware"
	"InstantImage/tcpService"
	"net/http"

	"github.com/gin-gonic/gin"
)

func SetUpRoutes(service *tcpService.TcpService) *gin.Engine {
	gin.SetMode(gin.ReleaseMode)
	r := gin.Default()
	r.Use(middleware.CacheMiddleware)
	r.LoadHTMLGlob("./web/*")
	r.StaticFile("/favicon.ico", "./static/favicon.ico")
	r.GET("/", getIndexHandler)
	r.POST("/upload", getUploadHandler(service))
	r.GET("/image/:key", getImageHandler(service))
	r.DELETE("/image/:key", getDeleteHandler(service))
	return r
}

func getIndexHandler(c *gin.Context) {
	c.HTML(http.StatusOK, "index.html", gin.H{})
}
